#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>


int maxArea(int* height, int heightSize) {
    int* left = height;
    int* right = height + heightSize - 1;
    int V = 0;
    int Vmax = 0;
    while (left < right)
    {
        if (*left <= *right)
        {
            V = ((right - left) * (*left++));
        }
        else
        {
            V = ((right - left) * (*right--));
        }
        if (Vmax < V)
        {
            Vmax = V;
        }
    }
    return Vmax;
}

int main()
{
    int arr[] = { 1, 8, 6, 2, 5, 4, 8, 3, 7 };
    printf("%d\n", maxArea(arr, 9));
}